home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 43 / Mac Magazin and MacEasy Magazine CD - Issue 43.iso / Software / Entwickler / CCMArea / Source / CCMEditText.cp < prev    next >
Encoding:
Text File  |  1998-02-10  |  1.6 KB  |  79 lines  |  [TEXT/CWIE]

  1. // CCMArea version 1.3.2
  2. // 2-10-98
  3. // by David Catmull
  4.  
  5. /* History:
  6.  
  7.     10-18-97        First created
  8.  
  9.     12-22-97        Updated for PowerPlant 1.8.1
  10.                             Removed Click()
  11.                             Updated ClickSelf to check CMClick's return value
  12.     
  13.     2-10-98            Only calls CMClick when active & enabled
  14. */
  15.  
  16. #include "CCMEditText.h"
  17. #include "CCMWindow.h"
  18. #include "UCMArea.h"
  19. #include <LControlImp.h>
  20. #include <Appearance.h>
  21.  
  22. void
  23. CCMEditText::FinishCreateSelf()
  24. {
  25.     // Make sure mSuperCMArea is set.
  26.     
  27.     if (!mSuperCMArea) {
  28.         LView *superView;
  29.         
  30.         UCMArea::FindSuperCMArea(this,mSuperCMArea,superView);
  31.     }
  32. }
  33.  
  34. void
  35. CCMEditText::ClickSelf(const SMouseDownEvent &inMouseDown)
  36. {
  37.     // True from CMClick means go ahead and handle the event
  38.     
  39.     if (IsEnabled() && IsActive())
  40.         if (CMClick(inMouseDown) == cm_Nothing)
  41.             LEditText::ClickSelf(inMouseDown);
  42. }
  43.  
  44. void
  45. CCMEditText::GetSelectionDesc(AEDesc &outSelDesc)
  46. {
  47.     OSErr err;
  48.     ControlEditTextSelectionRec selection;
  49.     TEHandle teH;
  50.     
  51.     // Return either the current selection, or the entire text.
  52.     
  53.     teH = GetMacTEH();
  54.     GetSelection(selection);
  55.     if (selection.selStart == selection.selEnd)
  56.         err = AECreateDesc(typeChar,*(**teH).hText+selection.selStart,
  57.                                              selection.selEnd-selection.selStart,&outSelDesc);
  58.     else
  59.         err = AECreateDesc(typeChar,*(**teH).hText,(**teH).teLength,&outSelDesc);
  60. }
  61.  
  62.  
  63. void
  64. CCMEditText::BuildMenuSelf(MenuHandle inMenu)
  65. {
  66.     UCMArea::AddCommandToMenu(inMenu,cmd_Cut);
  67.     UCMArea::AddCommandToMenu(inMenu,cmd_Copy);
  68.     UCMArea::AddCommandToMenu(inMenu,cmd_Paste);
  69.     UCMArea::AddCommandToMenu(inMenu,cmd_SelectAll);
  70. }
  71.  
  72. void
  73. CCMEditText::PreClick(const SMouseDownEvent &inMouseDown)
  74. {
  75. #pragma unused (inMouseDown)
  76.     
  77.     LCommander::SwitchTarget(this);
  78. }
  79.